/*********************************************************************************
 * 
 * Author: wujunjie
 * Create Date: 2014-05-10
 * Description:
 *          
 * Revision History:
 *      Date          Author               Description
 * 
*********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataFrameworkAccess;
using Xinkui.Entity.AutoGenerator;
using Xinkui.Common;
namespace Xinkui.DataAccess.AutoGenerator {
    public partial class CommonProvinceDataAccess
    {
        public List<CommonProvince_Entity> CommonProvince_ListByPaging(int pageSize, int pageIndex,out int total)
        {
			total= 0;
            try
            {
				int tempRecord = 0;
                DataCommand cmd = DataCommandManager.GetDataCommand("CommonProvince_ListByPaging");
                cmd.SetParameterValue("@PageSize", pageSize);
                cmd.SetParameterValue("@PageIndex", pageIndex);
				cmd.SetParameterValue("@RecordCount", tempRecord);
                List<CommonProvince_Entity> pageList = cmd.ExecuteEntityList<CommonProvince_Entity>();
                total = Convert.ToInt32(cmd.GetParameterValue("@RecordCount"));
				return pageList;
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }

            return new List<CommonProvince_Entity>(0);

        }

        public CommonProvince_Entity CommonProvince_View(System.Int32 ProvinceID)
        {
            CommonProvince_Entity c = default(CommonProvince_Entity);
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("CommonProvince_View");
                cmd.SetParameterValue("@ProvinceID", ProvinceID);
                c = cmd.ExecuteEntity<CommonProvince_Entity>();
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }
            return c;
        }

        public CommonProvince_Entity CommonProvince_Add(CommonProvince_Entity entity)
        {
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("CommonProvince_Add");
                cmd.SetParameterValue("@ProvinceID", entity.ProvinceID);
                cmd.SetParameterValue("@Province_CN", entity.Province_CN);
                cmd.SetParameterValue("@Province_EN", entity.Province_EN);
                cmd.SetParameterValue("@CountryID", entity.CountryID);
                cmd.SetParameterValue("@OrderBy", entity.OrderBy);
                cmd.SetParameterValue("@BlockChina", entity.BlockChina);
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }

            return entity;
        }

        public bool CommonProvince_Update(CommonProvince_Entity entity)
        {
            bool succ = false;
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("CommonProvince_Update");
                cmd.SetParameterValue("@ProvinceID", entity.ProvinceID);
                cmd.SetParameterValue("@Province_CN", entity.Province_CN);
                cmd.SetParameterValue("@Province_EN", entity.Province_EN);
                cmd.SetParameterValue("@CountryID", entity.CountryID);
                cmd.SetParameterValue("@OrderBy", entity.OrderBy);
                cmd.SetParameterValue("@BlockChina", entity.BlockChina);
                cmd.ExecuteNonQuery();
                succ = true;
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }
            return succ;
        }

        public bool CommonProvince_Delete(System.Int32 ProvinceID)
        {
            bool succ = false;
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("CommonProvince_Delete");
                cmd.SetParameterValue("@ProvinceID", ProvinceID);
                cmd.ExecuteNonQuery();
                succ = true;
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }
            return succ;
        }
		
	}
}
